//
//  WYCbankViewController.m
//  掌上还
//
//  Created by 王晓民 on 2018/1/13.
//  Copyright © 2018年 中企互联. All rights reserved.
//

#import "WYCbankViewController.h"

@interface WYCbankViewController ()<UIWebViewDelegate>
@property (nonatomic,strong)UIWebView *bankwebView;
@property (nonatomic,strong)NSArray  *addressArr;
@property (nonatomic,strong)NSString  *strUrl;

@end

@implementation WYCbankViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = WYCGlobalBg;
    [self setupNav];
    _addressArr = @[@"xy",@"pf",@"ms",@"jt",@"gd",@"gdbj",@"pa",@"gs",@"msxsk"];
    _bankwebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, NavHeight, ScreenWidth, ScreenHeight)];
    if ([_bankTitle isEqualToString:@"兴业银行"])
    {
        _strUrl = @"https://ccshop.cib.com.cn:8010/application/cardapp/newfast/ApplyCard/toSelectCard?id=918cdd519d4b42b28570e0ae6b30dc49";

    }
    else if ([_bankTitle isEqualToString:@"浦发银行"])
    {
        _strUrl = @"https://ecentre.spdbccc.com.cn/creditcard/indexActivity.htm?data=P1693370&itemcode=lianlong20";

    }
    else if ([_bankTitle isEqualToString:@"平安银行"])
    {
        _strUrl = @"https://c.pingan.com/ca/index?sign=cd888b22d959f7823600310f5c9bb2aa&versionNo=R10310&scc=232000407&channel=WX&onlineSQFlag=N&cardCatenaNo=06a07a01a02a03a04a05&isDisplayRecommend=N&isDisplaySales=Y&bt9=ZY&mt=SC200000659";
    }
    else if ([_bankTitle isEqualToString:@"招商银行"])
    {
        _strUrl = @"https://ccclub.cmbchina.com/mca/MPreContract.aspx?cardsel=&WT.mc_id=N57FHXM2073F677300HZ&dsid=XHLTX0455";
    }
    else if ([_bankTitle isEqualToString:@"中信银行"])
    {
        _strUrl = @"http://m.cards.ecitic.com/mgmpt/index.html?sid=SJHZF58&uid=SJZSXHL121";

    }
    else if ([_bankTitle isEqualToString:@"光大银行"])
    {
    
        _strUrl = @"https://xyk.cebbank.com/cebmms/apply/ps/card-list.htm?level=124&pro_code=FHTG183718SJ08HLTX";

    }
    else if ([_bankTitle isEqualToString:@"交通银行"])
    {
        _strUrl = @"https://creditcardapp.bankcomm.com/applynew/front/apply/track/record.html?trackCode=A013017006291";

    }
    NSLog(@"wqc=======%@",_strUrl);
    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:_strUrl]];
    [self.view addSubview: _bankwebView];
    [_bankwebView loadRequest:request];
    
}
//Nav字体颜色+ 背景
- (void)setupNav {
    self.navigationItem.title = _bankTitle;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self.navigationController.navigationBar setBarTintColor:wycMain];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    
    
    self.navigationController.navigationBar.hidden = YES;
    
    
    UIView * NavView = [[UIView alloc] init];
    NavView.frame = CGRectMake(0, 0, ScreenWidth, NavHeight);
    NavView.backgroundColor = WYCmainColor;
    [self.view addSubview:NavView];
    
    
    
    CALayer* bottomLineLayer = [[CALayer alloc] init];
    bottomLineLayer.frame = CGRectMake(0, NavView.bounds.size.height - 0.5, NavView.bounds.size.width, 0.5);
    bottomLineLayer.backgroundColor = WYCRGBColor(191, 191, 196).CGColor;
    [NavView.layer addSublayer:bottomLineLayer];
    
    
    
    
    
    //返回按钮
    UIButton *  fanhuibutton = [[UIButton alloc] init];
    [fanhuibutton setImage:[UIImage imageNamed:@"Nav_back"] forState:UIControlStateNormal];
    [fanhuibutton addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    fanhuibutton.frame = CGRectMake(30 * px, titleY, 66 * px , 66 * px);
    [NavView addSubview:fanhuibutton];
    
    
    UILabel * NavRigsterLabel = [[UILabel alloc] init];
    NavRigsterLabel.frame = CGRectMake(0, titleY, NavView.width, 68 * px);
    NavRigsterLabel.textColor = [UIColor whiteColor];
    NavRigsterLabel.font = [UIFont boldSystemFontOfSize:BigFont];
    NavRigsterLabel.textAlignment = NSTextAlignmentCenter;
    NavRigsterLabel.text = _bankTitle;
    [NavView addSubview:NavRigsterLabel];
}
- (void)backClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}

@end
